import sys,socket

testPort = 3389

okIPs = []
for i in xrange(1,255):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    ip = r'192.168.1.%d' % (i)
    try:
        s.connect((ip,testPort))
        s.close()
        print '%s: OK' % ip
        okIPs.append(ip)
    except:
        print '%s: Failed' % ip
print okIPs

